from pydantic import BaseModel, Field


class Work(BaseModel):
    """
    作品信息
    """
    name: str = Field(..., description="著作名称")
    author: str = Field(..., description="作者姓名")
    description: str = Field(..., description="著作的简要介绍")


class Discipline(BaseModel):
    """
    学科信息
    """
    name: str
    category: str
    super_disciplines: list[str] = []
    discipline_level: int = None
    related_disciplines: list[str] = []
    prerequisites: list[str] = []
    description: str = '暂无描述'
    history: str = '略'
    famous_works: list[Work] = []
    source: list[str] = []


class DisciplineDetail(BaseModel):
    description: str = Field("暂无描述", description="学科的简要介绍")
    history: str = Field("暂无描述", description="学科的发展历史概述")
    famous_works: list[Work] = Field([], description="学科的代表著作，包含著作名称、作者以及著作的简要介绍")


class DisciplineNodeView(BaseModel):
    name: str
    category: str
    x: float
    y: float


class DisciplineLinkView(BaseModel):
    source: str
    target: str


class DisciplineCategoryView(BaseModel):
    name: str


class DisciplineDataView(BaseModel):
    nodes: list[DisciplineNodeView]
    links: list[DisciplineLinkView]
    categories: list[DisciplineCategoryView]
    original_data: dict[str, Discipline]
